package com.lanlian.cayman.adapter;

import android.content.Context;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lanlian.cayman.R;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <pre>
 *     author : huxiaobo
 *     e-mail : huxiaobo@xlanlian.com
 *     date   : 2018/8/15 16:55
 *     desc   : 跟单选择合约Adapter
 *     version: 1.0
 * </pre>
 */
public  class ChooseBeiShuAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    private Context mContext;
    private Map<String, Boolean> mMaps = new HashMap<>();
   // private List<String> data;
    List<String> mlist;
    public ChooseBeiShuAdapter(Context context, int layoutResId, List<String> list) {
        super(layoutResId,list);
        this.mContext = context;
       // this.data = data;
        mlist=list;
        for (int i=0;i<mlist.size();i++) {

            mMaps.put(mlist.get(i), false);
        }
    }




    public void setChecked(String s) {
        for (int i=0;i<mlist.size();i++) {
            mMaps.put(mlist.get(i), false);
        }
        mMaps.put(s, true);
        notifyDataSetChanged();
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        helper.setText(R.id.tv_contract_name, item);

        helper.setChecked(R.id.cb_contract, mMaps.get(item));
    }
}
